package impl;

import java.util.Date;
import java.util.List;

import api.FriendSummary;
import api.IAuthenticator;
import api.IFacade;
import api.ILotteryProxy;
import api.ISocializer;
import api.IUserDataManager;
import api.IWallet;
import api.Lottery;

import javax.ejb.EJB;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;

import entities.Lindenmovementstype;

/**
 * Session Bean implementation class Facade
 */
@Stateful(name="IFacade")
public class Facade implements IFacade {

	
	@EJB(beanName="IAuthenticator")
	IAuthenticator authenticator;
	@EJB(beanName="ILotteryProxy")
	ILotteryProxy lotteryProxy;
	@EJB(beanName="ISocializer")
	ISocializer socializer;
	@EJB(beanName="IUserDataManager")
	IUserDataManager dataManager;
	@EJB(beanName="IWallet")
	IWallet wallet;
	
	int uid;
	boolean authenticated;
	
    /**
     * Default constructor. 
     */
    public Facade() {
        // TODO Auto-generated constructor stub
    	
    	authenticated = false;
    }

	@Override
	public boolean registerUser(String username, String password) {
		// TODO Auto-generated method stub
		
		System.out.println("*** FACADE ***");
		EntityManagerFactory emf;
		EntityManager em;
		
		emf = Persistence.createEntityManagerFactory("PhaseBookPU");
        em = emf.createEntityManager();
        
		EntityTransaction tx = em.getTransaction();
		tx.begin();
		
		Lindenmovementstype mType = new Lindenmovementstype();
        
		mType.setDescription("Test 1");
		
        em.persist(mType);
        
		System.out.println("*** PERSISTED ***");

        
        //tx.commit();
		
		
		
		return this.authenticator.registerUser(username, password);
		
	}

	@Override
	public boolean authenticate(String username, String password) {
		
		
		return false;
	}

	@Override
	public Date getLastLogin(String username) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean resetPassword(String username) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean registerBet(int uid, int choice) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Lottery getActiveLotteryDetails() {
		// TODO Auto-generated method stub

		System.out.println("*** FACADE ***");
		this.lotteryProxy.getActiveLotteryDetails();

		return null;
	}

	@Override
	public List<FriendSummary> searchFriends(String searchString) {
		// TODO Auto-generated method stub
		System.out.println("*** FACADE ***");

		return null;
	}

	@Override
	public boolean sendFriendshipInvitation(int fromId, int toId) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public List<FriendSummary> getPendingFriendshipRequests(int uid) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean confirmFriendshipRequest(int uid, int requesterdId) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isFriendWith(int baseId, int friendId) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean publishPublicMessage(int ownerId, int posterId,
			String message) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean publishPrivateMessage(int ownerId, int posterId,
			String message) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean getPublicMessageList(int uid) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean getPrivateMessageList(int uid) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean updateName(int uid, String name) {
		// TODO Auto-generated method stub
		System.out.println("*** FACADE ***");

		return false;
	}

	@Override
	public boolean updateAge(int uid, int age) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean updateCity(int uid, String city) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean updateGender(int uid, Gender sex) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean updateEmail(int uid, String email) {
		// TODO Auto-generated method stub
		System.out.println("*** FACADE ***");

		return false;
	}

	@Override
	public boolean updateNotificationApproach(int uid,
			NotificationApproach approach, boolean flag) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public String getProfileById(int uid) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getProfileByUsername(String username) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean reloadLinden(int uid, int amount) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean getMovements(int uid) {
		// TODO Auto-generated method stub
		return false;
	}

	

}
